#include "test_common.h"


int show_open_box(char* file_name, const char* _filter)
{
    #ifdef __WIN32__
    char filename[1024] = "";
    char filetitle[1024] = "";
    char filter[256] = "";
    char initdir[256] = ".\\";
    char title[256] = "Open XML";

    int n = strlen(_filter);
    int i;
    for (i = 0; i < n; i++)
    {
        if (_filter[i] == '|')
            filter[i] = 0;
        else
            filter[i] = _filter[i];
    }
    filter[i] = 0;

    OPENFILENAME ofn;
    memset(&ofn, 0, sizeof(ofn));
    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = NULL;
    ofn.hInstance = GetModuleHandle(NULL);
    ofn.lpstrFilter = filter;
    ofn.nFilterIndex = 1;
    ofn.lpstrFile = filename;
    ofn.nMaxFile = 1024;
    ofn.lpstrFileTitle = filetitle;
    ofn.nMaxFileTitle = 1024;
    ofn.lpstrInitialDir = initdir;
    ofn.lpstrTitle = title;
    ofn.Flags = OFN_EXPLORER;

    if (GetOpenFileName(&ofn) == 0 || filename == NULL)
        return 0;

    strcpy(file_name, filename);
    return 1;
    #else
    return 0;
    #endif
}

